<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">回传</a>
            <a><cite>回传设置</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <!-- <div class="layui-inline">
                    <label class="layui-form-label w-auto">选择媒体：</label>
                    <div id="pMenu" style="width:100%;flex:1"></div>
                </div> -->
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">名称：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="name" id="name" placeholder="请输入回传名称">
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="back" lay-filter="back"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </script>
    <script>
        let params = {
            elem: '#back'
            , toolbar: '#toolbarDemo'
            , url: '/cps/back/list' //数据接口
            , id: 'back'
            ,page:true
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 80, sort: true }
                , { field: 'name', title: '名称', }

                , { title: '回传方式', width:100, templet: function (d) {
                        return d.type == 0 ? '按公共配置' : d.type == 1 ? '按自然日' : '仅回传首单'
                    }
                }
                , { field: 'echo_rate', title: '回传比例',templet: function (d) {
                        return d.back_rate_type == 1 ? d.pass+':'+d.leak : d.echo_rate
                    }}
                , { toolbar: '#tbBar', title: '操作', width: 150 }
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(back)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加', './info.html', 750, 650);
                }
            });
            table.on('tool(back)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    DeleteAjax('/cps/back/delete',{ id: obj.data.id },'back')
                } else if (event === 'edit') {
                    x_admin_show('编辑', `./info.html?id=${obj.data.id}`, 650, 650);
                }
            });

        });
        
        let selectParams = {
            url:'/cps/link/getLaunchMedia',
            selected:[],
            tips:'选择媒体',
            name: 'media_id',
            field_id:'id',
            field_Name:'name',
            elem: '#pMenu'
        }
        selectN(selectParams)
    </script>
</body>

</html>